package com.ebupt.migu.common.util;

import com.alibaba.fastjson.JSON;
import org.apache.kafka.common.serialization.Deserializer;
import org.apache.kafka.common.serialization.Serializer;

/**
 * @author liuyangyang@e-byte.com
 * @description: TODO
 * @date 2024/10/14 14:36
 */
public class JsonSerializer<T> implements Serializer<T> {

    @Override
    public byte[] serialize(String topic, T data) {
        if (data == null) {
            return null;
        }
        return JSON.toJSONBytes(data);
    }
}

